package com.cskaoyan.shopping.controller;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.mall.constant.ShoppingRetCode;
import com.cskaoyan.shopping.dto.HomePageResponse;
import com.cskaoyan.shopping.dto.NavListResponse;
import com.cskaoyan.shopping.service.IContentService;
import com.cskaoyan.shopping.service.IHomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 周子伟
 * @description ${主页显示}
 * @date: 2022/7/29 15:55
 */


@RestController
@RequestMapping("shopping")


public class PageController {
    @Autowired
    IHomeService iHomeService;

    @Autowired
    IContentService iContentService;


    @GetMapping("/homepage")

    public ResponseData getHomePage() {

        HomePageResponse response = iHomeService.homepage();

        if (response.getCode().equals(ShoppingRetCode.SUCCESS.getCode())) {

            return new ResponseUtil().setData(response.getPanelContentItemDtos());
        }
        return new ResponseUtil().setErrorMsg(response.getMsg());


    }


    @GetMapping("/navigation")

    public ResponseData getNavigation() {

        NavListResponse response = iContentService.queryNavList();
        ResponseData responseData = new ResponseData();
        if (response.getCode().equals(ShoppingRetCode.SUCCESS.getCode())) {
            return new ResponseUtil().setData(response.getPannelContentDtos());

        }

        return new ResponseUtil().setErrorMsg(response.getMsg());

    }


}




